package persistencia;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.jdbc.Connection;

public class Conexao {
	
	private String login = "root";
	private String senha = "35452812";
	private String host = "localhost";
	private String dbName = "FolhaPagamento";
	
	private String url = "jdbc:mysql://" + host + "/" + dbName;
	
	public Connection conexao = null;
	
	public Statement stmt = null;
	public ResultSet r = null;
	
	public Conexao()
	{
	}
	
	public Connection getConnection() throws IOException, InterruptedException
	{
		try {
			//mysql
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException ex) {
			return null;
		}
		
		try {
			this.conexao = (Connection) DriverManager.getConnection(url, login, senha);
		} catch (SQLException ex) {
			ex.getMessage();
			ex.getCause();
			ex.getErrorCode();
			return null;
		} catch (Exception e) {
			return null;
		}
		
		return this.conexao;
	}
	

}
